package com.acoffee.java.staticProxyExer;

/**
 * @author acoffee
 * @create 2021-11-16 9:49
 */
//接口
interface Cookie{
    void cooking();
}

//实现类
class CookieImpl implements Cookie{

    @Override
    public void cooking() {
        System.out.println("煮饭！");
    }
}

//代理类
class StaticProxy{
    private Cookie cookie;
    public StaticProxy(Cookie cookie){
        this.cookie = cookie;
    }

    public void cooking(){
        System.out.println("洗菜!");
        cookie.cooking();
        System.out.println("洗碗!");
    }
}
//测试类
public class StaticProxyTest {
    public static void main(String[] args) {
        StaticProxy staticProxy = new StaticProxy(new CookieImpl());
        staticProxy.cooking();
    }
}

